import { trimStr } from '@/utils'
import Cookies from 'js-cookie'

/* 根据路径获取文件名*/
export function getNameByPath(strPath) {
  const path = trimStr((!strPath ? Cookies.get('toRouterPath') : strPath), '/')
  if (!path) return ''
  let name = path.replace(new RegExp('/', 'gm'), '-')
  const i = name.indexOf('?')
  if (i > 0) {
    name = name.substring(0, i)
  }
  if (name === '#' || name === '') name = 'dashboard-index'
  // console.log(name)
  return name
}
